﻿/*---------------------------------------------------------------- 
// Copyright 2005-2016 My Tech. Co. Ltd. All Rights Reserved.
// 版权所有。  
// 
// 文件名： CradleHeadBll
// 文件功能描述： 
// 
//  
// 创建标识： wx2016/11/11 16:38:35
// 
// 修改标识： 
// 修改描述： 
//----------------------------------------------------------------*/

using MyBLL.Dto;
using MyMiddleware;
using MyMiddleware.Radars.SP100;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyBLL
{
    public class SP100Bll
    {
        private static Device device;

        //线程安全的接收消息队列
        public static ConcurrentQueue<List<MyMiddleware.Radars.SP100.TargetInfo>> SP100TargetQueue = new ConcurrentQueue<List<MyMiddleware.Radars.SP100.TargetInfo>>();

        /// <summary>
        /// 获取校验和，出去命令头两个字节的累加和计算
        /// </summary>
        /// <param name="comand">指令</param>
        /// <returns></returns>
        private static byte[] checkComand(byte[] comand)
        {
            byte checksum = 0;
            for (int i = 2; i < comand.Length - 1; i++)
            {
                checksum += comand[i];
            }
            comand[comand.Length - 1] = checksum;
            return comand;
        }

       
        public static void device_OnGetData(object sender, DataEventArgs args)
        {
            byte[] data = args.MyData;
            List<MyMiddleware.Radars.SP100.TargetInfo> ptzInfos = ((SP100EventArgs)args).Targets;
            SP100TargetQueue.Enqueue(ptzInfos);
        }
    }
}
